import { Injectable, Logger } from '@nestjs/common';
import { CreateOrderInfoDto } from './dto/create-order_info.dto';
import { UpdateOrderInfoDto } from './dto/update-order_info.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { CustomerInfo } from '../../daijia_customer/customer_info/entities/customer_info.entity';
import { Repository } from 'typeorm';
import { SuccessResponse } from '../../../util/ResultResponse';
import { OrderInfo } from './entities/order_info.entity';

@Injectable()
export class OrderInfoService {

  private readonly logger: Logger = new Logger('OrderInfoService');

  constructor(
    @InjectRepository(OrderInfo)
    private readonly orderInfoRepository: Repository<OrderInfo>,
  ) {}

  create(createOrderInfoDto: CreateOrderInfoDto) {
    return 'This action adds a new orderInfo';
  }

  async findAll() : Promise<SuccessResponse<OrderInfo[]>>  {
    return await this.orderInfoRepository.find().then(result => {
      return {
        code: 0,
        data: result,
        message: '成功',
      };
    })
  }

  findOne(id: number) {
    return `This action returns a #${id} orderInfo`;
  }

  update(id: number, updateOrderInfoDto: UpdateOrderInfoDto) {
    return `This action updates a #${id} orderInfo`;
  }

  remove(id: number) {
    return `This action removes a #${id} orderInfo`;
  }
}
